/* eslint-disable no-undef */
const inquirer = require("inquirer");
const { toastCreateViewType, toastFileName } = require("./utils/cli");
const { createViewFile, createComponentType } = require("./utils/file");

const run = async () => {
  const fileType = await inquirer.prompt([
    {
      type: "list",
      message: "😋 您要创建以下哪种操作?",
      name: "type",
      default: "创建页面",
      choices: ["创建页面", "生成组件类型文件"],
    },
  ]);

  // 判断 是不是 view

  console.log("fileType ===>", fileType);
  if (fileType?.type === "创建页面") {
    // 询问 默认类型
    const viewType = await toastCreateViewType();
    const fileName = await toastFileName();
    console.log({ viewType });
    console.log({ fileName });
    createViewFile(fileName.path, fileName.name, viewType.type);
  } else {
    createComponentType();
  }
};

run();
